package com.angel.web.health;

import javax.servlet.http.HttpServletRequest;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import com.angel.core.util.JsonUtil;
import com.angel.core.util.Pager;
import com.angel.health.BuzSurveyAttr;
import com.angel.provider.health.BuzSurveyAttrProvider;

@Controller
@RequestMapping("/surveyAttr")
public class BuzSurveyAttrController {

	@Autowired
	private BuzSurveyAttrProvider provider;
	
	@RequestMapping("/index")
	public String index(BuzSurveyAttr surveyAttr,HttpServletRequest request,Pager pager){
		Pager bean = provider.findAll(surveyAttr,pager);
		request.setAttribute("pager", bean);
		return "";
	}
	
	@RequestMapping("/save")
	@ResponseBody
	public String save(BuzSurveyAttr surveyAttr){
		int i = provider.insert(surveyAttr);
		return JsonUtil.toJson(i);
	}
	
	@RequestMapping("/edit")
	@ResponseBody
	public String edit(Integer id){
		BuzSurveyAttr surveyAttr = provider.findById(id);
		return JsonUtil.toJson(surveyAttr);
	}
	
	@RequestMapping("/update")
	@ResponseBody
	public String update(BuzSurveyAttr surveyAttr){
		int i = provider.updateById(surveyAttr);
		return JsonUtil.toJson(i);
	}
}
